package com.qf.lanzhou.blog.api.controller;

import com.qf.lanzhou.blog.api.service.UserService;
import com.qf.lanzhou.blog.api.service.impl.UserServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Yeach-chen
 * @ClassName DeleteUserServlet
 */
@WebServlet("/delete.do")
public class DeleteUserServlet extends BaseServletPost{
    UserService userService=new UserServiceImp();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取参数
        String userName = req.getParameter("userName");
        System.out.println(userName);
        int result;
        try{
            result = userService.deleteUser(userName);
            successResultWrite(result,resp);
        }catch (RuntimeException e){
            String message = e.getMessage();
            failedResultWrite(message,resp);
        }
    }
}
